<template>
  <!-- <UnderDevelopment /> -->
  <div class="view">
    <div class="card">
      <div class="title">
        <div class="text">
          参数配置
        </div>
        <u-divider></u-divider>
      </div>
      <div class="content">
        <div class="item">
          <lRadio label="是否需要绑定读者证" v-model="formData.is_reader" :options="[{label: '是',value:1},{label:'否',value:2}]" />
          <lRadio label="是否需要报名" v-model="formData.is_apply" :options="[{label: '是',value:1},{label:'否',value:2}]" />
          <lRadio label="是否需要审核" v-model="formData.is_check" :options="[{label: '是',value:1},{label:'否',value:2}]" />
          <lRadio label="是否刷二维码进场" v-model="formData.is_qr" :options="[{label: '是',value:1},{label:'否',value:2}]" />
          <lRadio label="取消后能否再次报名" v-model="formData.is_continue" :options="[{label: '是',value:1},{label:'否',value:2}]" />
          <lRadio label="报名限制" v-model="formData.is_real" :options="[{label: '需实名',value:1},{label:'无需实名',value:2}]" />
          <lSelect label="签到方式" v-if="formData.is_qr==1" v-model="formData.sign_way" :columns="[{label:'全部',value: 1},{label:'用户自主扫码',value: 2},{label:'管理员设备扫码',value: 3}]" placeholder="请选择"></lSelect>
          <!-- <lRadio label="实名所需信息" multiple v-model="formData.real_info" :options="realInfoList"></lRadio> -->
        </div>
      </div>

    </div>

    <div class="card">
      <div class="title">
        <div class="text">
          活动设置
        </div>
        <u-divider></u-divider>
      </div>
      <div class="content">
        <lUploadImg label="活动封面" />
        <l-input v-model="formData.name" label="活动名称" />
        <lSelect label="活动标签" v-model="formData.tag" :height="92" :rule="rules.tag" :columns="[{label:'扫码bb',value: 'id'}]" placeholder="请选择">
          <template #label>
            <div>
              <div class="label">活动标签</div>
              <div class="link">管理标签预设</div>
            </div>
          </template>
        </lSelect>
        <lSelect label="活动类型" v-model="formData.type" :height="92" :rule="rules.tag" :columns="[{label:'扫码bb',value: 'id'}]" placeholder="请选择">
          <template #label>
            <div>
              <div class="label">活动标签</div>
              <div class="link">管理类型预设</div>
            </div>
          </template>
        </lSelect>
        <l-intro label="简介" v-model="formData.intro" placeholder="请输入内容" />
        <l-Number label="活动名额" v-model="formData.num" :min="6" :max="12"></l-Number>
        <l-intro label="活动地址" v-model="formData.intro" placeholder="请输入 (注：请认真填写地址，地址有误可能会导致签到异常)" />
        <l-input label="联系人姓名" v-model="formData.name" />
        <l-input label="联系人电话" v-model="formData.phone" />
        <l-limit label="年龄限制" v-model="formData" keyType="type" keyStart="start_age" keyEnd="end_age" :showNum="1" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { catchException, request } from '@/util/request'

const title = ref('')
const rules = {
  tag: { require: true, message: '请选择标签' }
}

const formData = ref({
  reader_card: '',
  num: 1
})

// realInfoList信息获取
const realInfoList = ref([])
function getRealInfoParam() {
  request({ url: 'adminMobile/activity/getActivityApplyParam' }).then(res => {
    realInfoList.value = res.content.map(item => {
      return {
        label: item.value,
        value: item.id
      }
    })
  }).catch(e => catchException(e))
}

onLoad((opt) => {
  if (opt.id) {
    title.value = '创建活动'
  } else {
    title.value = '修改活动'
  }
  getRealInfoParam()
})

</script>

<style lang="scss" scoped>
page {
  background: #f3f3f3;
}
.view {
  padding: 30rpx;
  display: flex;
  flex-direction: column;
  gap: 30rpx;
}
.card {
  padding: 0 20rpx 0 20rpx;
  background: #ffffff;
  border-radius: 16rpx;
  .title {
    font-family: PingFang SC, PingFang SC-Bold;
    font-weight: 700;
    text-align: left;
    color: #333333;
    background: #ffffff;
    border-radius: 16rpx;
    padding: 20rpx 0 10rpx 0;
    position: relative;
    .u-divider {
      margin: 0;
    }
    .text {
      padding-bottom: 20rpx;
      padding-left: 30rpx;
      font-size: 32rpx;
      border-radius: 16rpx;
    }
    .text::before {
      position: absolute;
      content: "";
      width: 6rpx;
      height: 36rpx;
      background: #468eff;
      left: 6rpx;
      top: 25rpx;
    }
  }
}

.content {
  padding-bottom: 12rpx;
}
.link {
  font-size: 24rpx;
  font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  font-weight: 400;
  text-decoration: underline;
  text-align: center;
  color: #468eff;
}
</style>